
// 【异步 封装本地存储】

// 插入数据
export const _setStorageAsyn = (key, value) => {
  return new Promise((resolve) => {
    wx.setStorage({
      key, //如果形参跟实参名字一样，可以省略写成一样的
      data: value,
      complete(res) {
        resolve(res)
      }
    })
  })
}

// 查询数据
export const _getStorageAsyn = (key) => {
   return new Promise((resolve) => {
     wx.getStorage({
       key,
       complete(res) {
         resolve(res)
       }
     })
   })
}

// 删除数据
export const _removeStorageAsyn = (key) => {
  return new Promise((resolve) => {
    wx.removeStorage({
      key,
      complete(res) {
        resolve(res)
      }
    })
  })
}

// 清空本地存储
export const _clearStorageAsyn = () => {
  return new Promise((resolve) => {
    wx.clearStorage ({
      complete(res) {
        resolve(res)
      }
    })
  })
}
